Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement negation #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Implement negation #30

wants to merge 1 commit into from

Conversation

ip1981
Copy link

@ip1981 ip1981 commented May 25, 2023

No description provided.

Copy link
Contributor

@jhugman jhugman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ip1981 Thank you so much for fixing this!

It's been on my list for so long, but I haven't had the brain space to learn how lalrpop works.

I've added a couple of comments below: the biggest thing to fix is the precedence ordering, and naming.

I think you'll likely end up making an UnOp60 (or similarly named rule).

Once you get operator precedence squared away, re-request a review from me!

Many thanks, again!

@@ -116,6 +117,10 @@ Op50: OpCode = {
"^" => OpCode::Exponent,
};

Op60: UnOpCode = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: given this is at Expr70 level, to follow the rest of the code, could we name this Op80?

@@ -67,6 +67,7 @@ Expr60: Box<Expression> = {
Expr70: Box<Expression> = {
<subject: Expr70> <index: Index> => Box::new(Expression::IndexOperation{subject, index}),
<subject: Expr70> "." <ident: Identifier> => Box::new(Expression::DotOperation{subject, ident}),
<operation: Op60> <right: Expr80> => Box::new(Expression::UnaryOperation { operation, right }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should . and [ bind tighter than !? Playground with the jexl-js.

I couldn't see a test, and I'm not familiar enough with lalrpop know. Please could you add tests verifying the following work:

foo == [false]
!foo[0] == true
foo == { "bar": false }
!foo.bar  == true

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've updated my patch fixing priorities, naming, adding the tests you suggested.

@fgalan
Copy link

fgalan commented May 14, 2024

I would be great if this PR could be merge to implement the ! operator that original JavaScript JEXL implementation provides :)

@fgalan
Copy link

fgalan commented May 17, 2024

I would be great if this PR could be merge to implement the ! operator that original JavaScript JEXL implementation provides :)

...and also it seems it would help to make the unary minus to work (issue #27)!

Signed-off-by: Igor Pashev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants